﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace BIPorter.Common.Model
{
    public class MeunModel
    {

        #region 属性


        /// <summary>
        /// 编号Id
        /// </summary>
        public int Id { private set; get; }

        /// <summary>
        /// 父级Id
        /// </summary>
        public int? ParentId { private set; get; }

        /// <summary>
        /// 显示文字
        /// </summary>
        public string DisplayName { private set; get; }

        /// <summary>
        /// 操作
        /// </summary>
        public string ActionName { private set; get; }

        /// <summary>
        ///  控制器
        /// </summary>
        public string ControllerName {private set; get; }

        /// <summary>
        /// 服务器地址和端口号
        /// </summary>
        public string Server { set; get; }

        /// <summary>
        /// 菜单URL
        /// </summary>
        public string MeunUrl
        {
            get { return string.Format("http://{0}/{1}/{2}", 
            Server, ControllerName, ActionName); }
        }

        /// <summary>
        /// 支持的角色
        /// </summary>
        public string Role { set; get; }

        /// <summary>
        /// 字节点
        /// </summary>
        public List<MeunModel> ChildMenus { set; get; }


        #endregion

        #region 构造函数

        public MeunModel(int id,string displayName, string actionName,
        string controllerName, string server, string role, int? parentId = null)
        {
            this.Id = id;
            this.DisplayName = displayName;
            this.ActionName = actionName;
            this.ControllerName = controllerName;
            this.Server = server;
            this.Role = role;
            this.ParentId = parentId;
        }

        #endregion
    }
}